package service.Impl;

import bean.Pest;
import dao.IPestDao;
import dao.impl.PestDaoImpl;
import service.IPestService;
import util.PageUtil;

import java.util.List;

public class PestServiceImpl implements IPestService {

    IPestDao ipd =new PestDaoImpl();
    @Override
    public PageUtil<Pest> ListByPage(int pageNo, int pageSize) {
        List<Pest> pests =ipd.ListByPage(pageNo,pageSize);
        int count =ipd.getCount();
        PageUtil<Pest> pages =new PageUtil<>(pests,count,pageNo,pageSize);
        return pages;
    }

    @Override
    public boolean addPest(Pest p) {
        return ipd.addPest(p)>0?true:false;
    }

    @Override
    public PageUtil<Pest> ListByPage(int pageNo, int pageSize, String pestName, String pestHost) {
        List<Pest> pests =ipd.ListByPage(pageNo,pageSize,pestName,pestHost);
        int count =ipd.getCount(pestName,pestHost);
        PageUtil<Pest> pages =new PageUtil<>(pests,count,pageNo,pageSize);
        return pages;
    }
}
